package com.zjc.springboot.kafka.producer;

import com.zjc.springboot.kafka.ChannelDefinition;
import com.zjc.springboot.kafka.messages.BaseMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(ChannelDefinition.class)
public class KafkaProducer {

    @Autowired
    private ChannelDefinition source;

    public boolean sendMsg(final BaseMsg msg) {
        return source.testStormOutput().send(MessageBuilder.withPayload(msg).build());

    }
}
